package com.trip_memories;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.hardware.Camera;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.Toast;
import camera.CameraSurface;
import camera.MyCamera;
import camera.PhotoHandler;

@SuppressLint("ShowToast")
public class CameraActivity extends Activity {

	protected static final int FOTO_MODE = 100;
	private Camera camera;
	private CameraSurface cameraview;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.preview);

		if (MyCamera.checkCamera(this)) {
			camera = MyCamera.getCameraInstance();
			cameraview = new CameraSurface(this, camera);
			FrameLayout frame = (FrameLayout) findViewById(R.id.camera_preview);
			frame.addView(cameraview);
		} else {
			Toast.makeText(this, "No camera found", Toast.LENGTH_LONG);
		}
	}

	public boolean onClick(View v) {
		camera.takePicture(null, null, new PhotoHandler(this));
		return true;
	}
	
	public boolean onCancel(View v){
		finish();
		return true;
	}

}